package m06;

import java.util.ArrayList;

/**
 * This class controls the Solar Systems. It constructs the Solar Systems and
 * places the constructed Solar Systems into an ArrayList.
 * 
 * @author Joshua Clark
 * @version 1.2 11 October 2012
 */

public class SolarSystem{
	/** The name of the Solar System */
	private String name;
	/** The X location of the Solar System */
	private int xloc;
	/** The Y location of the Solar System */
	private int yloc;
	/** The technology level of the Solar System */
	private String techLevel = "Agriculture";
	/** First resource of the Solar System */
	private String resource1;
	/** Second resource of the Solar System */
	private String resource2;
	/** Third resource of the Solar System */
	private String resource3;

	public SolarSystem ss01, ss02, ss03, ss04, ss05, ss06, ss07, ss08, ss09;


	/** The ArrayList that contains the created Solar Systems */
	private static ArrayList<SolarSystem> solarSystems = new ArrayList<SolarSystem>();



	/**
	 * This method creates the hard-coded Solar Systems, adds them to the 
	 * ArrayList, and prints the ArrayList.
	 */
	public void activateSolarSystem() {		
		ss01 = new SolarSystem("Titan", 50, 50, "Industrial", 
				"MINERALRICH", "WEIRDMUSHROOMS");
		ss02 = new SolarSystem("Demeter", 175, 100, "Agriculture", 
				"RICHSOIL", "RICHFAUNA", "LOTSOFHERBS");
		ss03 = new SolarSystem("Apollo", 100, 100, "Early Industrial", 
				"LOTSOFWATER", "POORSOIL", "WARLIKE");
		ss04 = new SolarSystem("Schwagger", 5, 195, "Post Industrial", 
				"LOTSOFWATER", "WEIRDMUSHROOMS", "ARTISTIC");
		ss05 = new SolarSystem("Argus", 160, 175, "Pre-Agriculture", 
				"POORSOIL", "LIFELESS", "LOTSOFHERBS");
		ss06 = new SolarSystem("Nix", 45, 120, "Renaissance", 
				"RICHFAUNA", "ARTISTIC");
		ss07 = new SolarSystem("Xerox", 120, 190, "Hi-Tech", 
				"MINERALPOOR", "POORSOIL", "ARTISTIC");
		ss08 = new SolarSystem("Isis", 10, 140, "Agriculture", "DESERT",
				"RICHSOIL");
		ss09 = new SolarSystem("Brax", 75, 125, "Medieval", "DESERT", 
				"WARLIKE");

		// Adding the Solar System objects to the ArrayList
		solarSystems.add(ss01);
		solarSystems.add(ss02);
		solarSystems.add(ss03);
		solarSystems.add(ss04);
		solarSystems.add(ss05);
		solarSystems.add(ss06);
		solarSystems.add(ss07);
		solarSystems.add(ss08);
		solarSystems.add(ss09);

		// Printing out the Solar System objects in the ArrayList
		//System.out.println(solarSystems);

	} // end method activateSolarSystem

	/** Just an empty constructor. */
	public SolarSystem() {
		activateSolarSystem();
	} // end of empty constructor

	/**
	 * This constructor takes in the parameters for the Solar System and is 
	 * chained to the other constructor. It sets the last resource to null and
	 * calls the second constructor.
	 * 
	 * @param name This is the name of the Solar System
	 * @param xloc This is the Solar Systems x location in the GUI window
	 * @param yloc This is the Solar Systems y location in the GUI window
	 * @param techLevel This is what type of technology the Solar System has
	 * @param rec1 This is the first resource
	 * @param rec2 This is the second resource
	 */
	public SolarSystem(String name, int xloc, int yloc, 
			String techLevel, String resource1, String resource2) {
		this(name, xloc, yloc, techLevel, resource1, resource2, null);
	} // end constructor

	/**
	 * This constructor takes in the parameters for the Solar System and sets 
	 * them equal to the instantiated variables.
	 * 
	 * @param name This is the name of the Solar System
	 * @param xloc This is the Solar Systems x location in the GUI window
	 * @param yloc This is the Solar Systems y location in the GUI window
	 * @param techLevel This is what type of technology the Solar System has
	 * @param rec1 This is the first resource of the Solar System
	 * @param rec2 This is the second resource of the Solar System
	 * @param rec3 This is the third resource of the Solar System
	 */
	public SolarSystem(String name, int xloc, int yloc, 
			String techLevel, String resource1, String resource2, 
			String resource3) {
		this.name = name;
		this.xloc = xloc;
		this.yloc = yloc;
		this.techLevel = techLevel;
		this.resource1 = resource1;
		this.resource2 = resource2;
		this.resource3 = resource3;
	} // end constructor

	/**
	 * This method returns the name of the Solar System.
	 * 
	 * @return The name of the Solar System.
	 */
	public String getName() {
		return name;
	} // end method getName(String)

	/**
	 * This method returns the x location of the Solar System.
	 * 
	 * @return The x location of the Solar System.
	 */
	public int getXLocation() {
		return xloc;
	} // end method getXLocation

	/**
	 * This method returns the y location of the Solar System.
	 * 
	 * @return The y location of the Solar System.
	 */
	public int getYLocation() {
		return yloc;
	} // end method getYLocation

	/**
	 * This method return the technology level of the Solar System.
	 * 
	 * @return The technology level of the Solar System
	 */
	public String getTechLevel() {
		return techLevel;
	} // end method getTechLevel

	/**
	 * This method returns the first resource of the Solar System.
	 * 
	 * @return The first resource of the Solar System.
	 */
	public String getResource1() {
		return resource1;
	} // end method getResources

	/**
	 * This method returns the second resource of the Solar System.
	 * 
	 * @return The second resource of the Solar System.
	 */
	public String getResource2() {
		return resource2;
	} // end method getResource

	/**
	 * This method returns the third resource of the Solar System.
	 * 
	 * @return The third resource of the Solar System.
	 */
	public String getResource3() {
		return resource3;
	} // end method getResource

	/**
	 * a tostring that returns a string representing the solar syste.
	 * @return the string
	 */
	@Override
	public String toString() {
		return this.getName() + "- Location: " + this.getXLocation() + ", " + 
				this.getYLocation() + "; Tech level: " + this.getTechLevel() + 
				"; Resources: " + this.getResource1() + ", " + 
				this.getResource2() + ", " + this.getResource3() + "\n";
	} // end method toString

} // end class SolarSystem
